﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Common
{
    /// <summary>
    /// Key/Value实体
    /// </summary>
    /// <typeparam name="TKey">Key数据类型</typeparam>
    /// <typeparam name="TValue">Value数据类型</typeparam>
    /// <remarks>
    /// <![CDATA[
    /// 此对象用于键值对不同数据类型时使用
    /// ]]>
    /// </remarks>
    /// <example>
    /// <code>
    /// <![CDATA[
    /// private void Test()
    /// {
    ///     //实例化一个新的健值对象
    ///     var keyValue = KeyValue.Instance(1, "Value");
    ///     Console.WriteLine("Key:" + keyValue.Key);
    ///     Console.WriteLine("Value:" + keyValue.Value);
    /// }
    /// ]]>
    /// </code>
    /// </example>
    [DebuggerDisplay("Key={Key}      Value={Value}")]
    public class KeyValue<TKey, TValue>
    {
        /// <summary>
        /// Key
        /// </summary>
        public TKey Key { get; set; }

        /// <summary>
        /// Value
        /// </summary>
        public TValue Value { get; set; }


    }

    /// <summary>
    /// 键值对象
    /// </summary>
    /// <remarks>
    /// <![CDATA[
    /// 此对象只是便于构造键值对对象
    /// ]]>
    /// </remarks>
    /// <example>
    /// <code>
    /// <![CDATA[
    /// private void Test()
    /// {
    ///     //实例化一个新的健值对象
    ///     var keyValue = KeyValue.Instance(1, "Value");
    ///     Console.WriteLine("Key:" + keyValue.Key);
    ///     Console.WriteLine("Value:" + keyValue.Value);
    /// }
    /// ]]>
    /// </code>
    /// </example>
    public class KeyValue
    {
        /// <summary>
        /// 创建一个键值对象
        /// </summary>
        /// <typeparam name="TKey">Key的类型</typeparam>
        /// <typeparam name="TValue">Value的类型</typeparam>
        /// <param name="key">Key值</param>
        /// <param name="value">Value值</param>
        /// <example>
        /// <code>
        /// <![CDATA[
        /// private void Test()
        /// {
        ///     //实例化一个新的健值对象
        ///     var keyValue = KeyValue.Instance(1, "Value");
        ///     Console.WriteLine("Key:" + keyValue.Key);
        ///     Console.WriteLine("Value:" + keyValue.Value);
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <returns>
        /// <![CDATA[
        /// 返回一个新的KeyValue<TKey, TValue>对象
        /// ]]>
        /// </returns>
        public static KeyValue<TKey, TValue> Instance<TKey, TValue>(TKey key, TValue value)
        {
            KeyValue<TKey, TValue> model = new KeyValue<TKey, TValue>()
            {
                Key = key,
                Value = value,
            };
            return model;
        }
        /*
        private void Test()
        {
            //实例化一个新的健值对象
            var keyValue = KeyValue.Instance(1, "Value");
            Console.WriteLine("Key:" + keyValue.Key);
            Console.WriteLine("Value:" + keyValue.Value);
        }
        */
    }
}
